<div class="modal fade " id="addCustScoreModal"   role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">新增企业评分</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal" id="addCustScoreForm">
                <div class="box-body">
                    <div class="form-group">
                        <label for="inptuEmail3" class="col-sm-2 control-label">企业选择</label>
                        <div class="col-sm-7">
                            <select id="addCustScoreIssuerId" class=" form-control select2" style="width: 100%">
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">财报时间</label>
                        <div class="col-sm-7">
                            <select id="addCustScoreModelId" class="form-control select2" style="width: 100%" >
                            </select>
                        </div>

                    </div>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"  >取消</button>

                    <button type="button" class="btn btn-primary pull-right" onclick="addCustScore()">新增</button>
                </div>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</div>
<script>
    function addCustScoreModalInit() {
        $("#addCustScoreIssuerId").val("-1").trigger("change");
        var url = "/custscore/custlist" ;
        getReq(url, function (result) {
            if (result.success) {
                var html = "";
                var list = result.customerInfoVos;
                for (var i = 0; i < list.length; i++) {
                    var o = list[i];
                    html = html + "<option value='" + o.issuerId + "'>" + o.custName + "</option> ";
                }
                $("#addCustScoreIssuerId").empty();
                $("#addCustScoreIssuerId").append(html);
                $('#addCustScoreIssuerId').select2();
            } else {
                alert(result.msg);
            }
        });
        var url = "/custscore/modellist";
        getReq(url, function (result) {
            if (result.success) {
                var html = "";
                var list = result.modelInfoVos;
                for (var i = 0; i < list.length; i++) {
                    var o = list[i];
                    html = html + "<option value='" + o.id + "'>" + o.name + "</option> ";
                }
                $("#addCustScoreModelId").empty();
                $("#addCustScoreModelId").append(html);
                $('#addCustScoreModelId').select2();
            } else {
                alert(result.msg);
            }
        });
    }


    function addCustScore() {
        var issuerId = $("#addCustScoreIssuerId").val() ;
        if(undefined == issuerId|| issuerId== "") {
            toastr['error']("请选择客户", '错误');
            return;
        }
        var modelId =  $("#addCustScoreModelId").val() ;
        if(modelId == "" || undefined == modelId) {
            toastr['error']("请选择财报时间", '错误');
            return;
        }
        var data = {
            issuerId : issuerId ,
            modelId : modelId
        };
        var url = "/custscore/add";
        postReq(url, data, function (result) {
            if (result.success) {
                addCustScoreModalInit();
                $("#custScoreTable").bootstrapTable("refresh");
                $("#addCustScoreModal").modal("hide");
                toastr['success']('新增企业评分成功', '提示');
            } else {
                toastr['error'](result.msg, '提示');
            }
        });
    }
</script>